<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>展示列表</title>
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">

    <script type="text/javascript" src="/js/jquery.js"></script>
    <script type="text/javascript">

        //表单执行delete方法
        function toDelete() {

            document.getElementById("method").value="delete";
            //选中第二个form表单
            document.forms[1].submit();
        }

        //表单执行导出表格方法
        function toOut(){
            document.getElementById("method").value="out";
            document.forms[1].submit();
        }


        //多选框全选
        $(function(){
            $("#btn1").click(function(){
                //1.得到点击按钮的状态  checked 属于js对象中的属性
                //jquery->js
                var state=$(this)[0].checked;
                //alert(state);
                //2.设置全选
                var cks=document.getElementsByName("bargainid");
                for(var i=0;i<cks.length;i++){
                    cks[i].checked=state;
                }
            });
        })
    </script>
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <h1 class="text-center text-warning">
                合同信息列表
            </h1>
            <div class="div_search">
                <span>
                    <button type="button" onclick="location.href='/bargain/add-ui'" class="btn btn-info">新增合同</button>
                    <button type="button" onclick="toOut()" class="btn btn-info">导出数据</button>
                    <button type="button" onclick="toDelete()" class="btn btn-info">批量删除</button>

                    <form action="/bargain/findAll" method="post">
                        机构名称:
					    <input type="text" name="charityname" value="${charityname!''}"/>
					    审核状态:
					        <select name="checkstatus">
                            <option value="-1">-- 请选择--</option>
                            <#list checkList as check>
                                <option value="${check.id!''}"
                                        <#if checkstatus == check.id>selected</#if> >${check.checkname!''}</option>
                            </#list>

                            </select>
                        合同类型:
                        <select  name="styleid">
                            <option value="-1">-- 请选择--</option>
                            <#list styleList as style>
                                <option value="${style.id!''}" <#if styleid == style.id>selected</#if> >${style.stylename!''}</option>
                            </#list>
                        </select>
                         <input value="查询" type="submit"/>

                    </form>
                </span>
            </div>
            <br/>

            <form action="/bargain/deleteOrOut" method="post">
                <#--设置隐藏域，通过id确定执行哪个方法-->
                <input type="hidden" name="method" id="method"/>

                <table class="table" width="100%">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th width="40px;"><input type="checkbox" id="btn1"/></th>
                        <th>合同名称</th>
                        <th>机构名称</th>
                        <th>合同类型</th>
                        <th>合同总金额</th>
                        <th>经办人</th>
                        <th>审核状态</th>
                        <th>签约时间</th>
                        <th>到期时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    <#list pageInfo.list as bargain>
                        <tr class="info">
                            <td>${bargain.id}</td>
                            <td><input type="checkbox" name="bargainid" value="${bargain.id}"/></td>
                            <td>${bargain.bargainname}</td>
                            <td>${bargain.charityname}</td>
                            <td>${bargain.stylename}</td>
                            <td>${bargain.count}元</td>
                            <td>${bargain.operator}</td>
                            <td>${bargain.checkname}</td>
                            <td>${bargain.contracttime?string('yyyy-MM-dd')}</td>
                            <td>${bargain.endtime?string('yyyy-MM-dd')}</td>
                            <td>
                                <button type="button" onclick="location.href='/bargain/update-ui?id=${bargain.id}'"
                                        class="btn btn-default btn-warning">编辑
                                </button>
                                &nbsp;&nbsp;&nbsp;&nbsp;
                                <button type="button"
                                        onclick="javascript:if(confirm('确定删除?'))location.href='/bargain/deleteById?id=${bargain.id}';"
                                        class="btn btn-default btn-danger">删除
                                </button>
                                &nbsp;&nbsp;&nbsp;&nbsp;
                                <button type="button" onclick="location.href='/bargain/info?id=${bargain.id}'"
                                        class="btn btn-info">查看
                                </button>
                            </td>
                        </tr>
                    </#list>

                    </tbody>
                </table>
            </form>
            <ul class="pagination">

                <#--<#if pageInfo.hasPreviousPage>-->
                    <li>
                        <a href="javascript:;" onclick="location.href='/bargain/findAll?page=1&size=${pageInfo.pageSize}&charityname=${charityname!''}&checkstatus=${checkstatus!''}&styleid=${styleid!''}'">首页</a>
                    </li>
                    <li>
                        <a href="javascript:;" onclick="location.href='/bargain/findAll?page=${pageInfo.prePage}&size=${pageInfo.pageSize}&charityname=${charityname!''}&checkstatus=${checkstatus!''}&styleid=${styleid!''}'">上一页</a>
                    </li>
                <#--</#if>-->

                <#--<#if pageInfo.pageNum lt pageInfo.pages>-->
                    <li>
                        <a href="javascript:;" onclick="location.href='/bargain/findAll?page=${pageInfo.nextPage}&size=${pageInfo.pageSize}&charityname=${charityname!''}&checkstatus=${checkstatus!''}&styleid=${styleid!''}'">下一页</a>
                    </li>
                    <li>
                        <a href="javascript:;" onclick="location.href='/bargain/findAll?page=${pageInfo.pages}&size=${pageInfo.pageSize}&charityname=${charityname!''}&checkstatus=${checkstatus!''}&styleid=${styleid!''}'">尾页</a>
                    </li>
                &nbsp;&nbsp;&nbsp;&nbsp;<h3>共${pageInfo.total}条 ${pageInfo.pageNum}/${pageInfo.pages}</h3>
                <#--</#if>-->
            </ul>
        </div>
    </div>
</div>

</body>
</html>